package com.local.goods.pojo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 在ElasticSearch搜索中，goods商品的索引
 */

public class GoodsESDoc implements Serializable {
    private Integer goodsId;
    private String goodsName;
    private String goodsIntro;
    private String tag;
    private String goodsCoverImg;
    private Integer sellingPrice;
    private List<String> suggestion;//搜索词的自动补全，即：在搜索框输入后，输入框下方出现的相关词提示

    public GoodsESDoc(){}

    public GoodsESDoc(Goods goods) {
        this.goodsId = goods.getGoodsId();
        this.goodsName = goods.getGoodsName();
        this.goodsIntro = goods.getGoodsIntro();
        this.tag = goods.getTag();
        this.goodsCoverImg = goods.getGoodsCoverImg();
        this.sellingPrice = goods.getSellingPrice();

        this.suggestion = new ArrayList<>();
        this.suggestion.add(goods.getGoodsName());
        this.suggestion.add(goods.getGoodsIntro());
        Collections.addAll(this.suggestion, goods.getTag().split(" "));
    }

    public Integer getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(Integer goodsId) {
        this.goodsId = goodsId;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public String getGoodsIntro() {
        return goodsIntro;
    }

    public void setGoodsIntro(String goodsIntro) {
        this.goodsIntro = goodsIntro;
    }

    public String getTag() {
        return tag;
    }

    public void setTag(String tag) {
        this.tag = tag;
    }

    public String getGoodsCoverImg() {
        return goodsCoverImg;
    }

    public void setGoodsCoverImg(String goodsCoverImg) {
        this.goodsCoverImg = goodsCoverImg;
    }

    public Integer getSellingPrice() {
        return sellingPrice;
    }

    public void setSellingPrice(Integer sellingPrice) {
        this.sellingPrice = sellingPrice;
    }

    public List<String> getSuggestion() {
        return suggestion;
    }

    public void setSuggestion(List<String> suggestion) {
        this.suggestion = suggestion;
    }

    @Override
    public String toString() {
        return "GoodsESDoc{" +
                "goodsId=" + goodsId +
                ", goodsName='" + goodsName + '\'' +
                ", goodsIntro='" + goodsIntro + '\'' +
                ", tag='" + tag + '\'' +
                ", goodsCoverImg='" + goodsCoverImg + '\'' +
                ", sellingPrice=" + sellingPrice +
                ", suggestion=" + suggestion +
                '}';
    }
}
